﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:diagram="clr-namespace:ttg_internal.Utilities.PipelineManager.Diagram"
    xmlns:controls="clr-namespace:ttg_internal.Utilities.PipelineManager.Diagram.Controls">

    <SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />
    
    

    <!-- Connector Style -->
    <!--<Style TargetType="{x:Type diagram:Connector}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Height" Value="8"/>
        <Setter Property="Cursor" Value="Cross"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type diagram:Connector}">
                    <Grid>
                         transparent extra space makes connector easier to hit 
                        <Rectangle Fill="Transparent" Margin="-2"/>
                        <Rectangle Fill="Lavender" StrokeThickness="1" Stroke="#AA000080"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>-->

    <!-- ConnectorDecoratorTemplate Default Template -->
    <!--<ControlTemplate x:Key="ConnectorDecoratorTemplate" TargetType="{x:Type Control}">
        <Grid Margin="-5">
            <diagram:Connector Orientation="Left" VerticalAlignment="Center" HorizontalAlignment="Left"/>
            <diagram:Connector Orientation="Top" VerticalAlignment="Top" HorizontalAlignment="Center"/>
            <diagram:Connector Orientation="Right" VerticalAlignment="Center" HorizontalAlignment="Right"/>
            <diagram:Connector Orientation="Bottom" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
        </Grid>
    </ControlTemplate>-->

    <!-- ResizeDecorator Default Template -->
    <ControlTemplate x:Key="ResizeDecoratorTemplate" TargetType="{x:Type Control}">
        <Grid Opacity="0.7" SnapsToDevicePixels="true">
            <controls:ResizeThumb Height="3" Cursor="SizeNS" Margin="0 -4 0 0"
                     VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
            <controls:ResizeThumb Width="3" Cursor="SizeWE" Margin="-4 0 0 0"
                     VerticalAlignment="Stretch" HorizontalAlignment="Left"/>
            <controls:ResizeThumb Width="3" Cursor="SizeWE" Margin="0 0 -4 0"
                     VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
            <controls:ResizeThumb Height="3" Cursor="SizeNS" Margin="0 0 0 -4"
                     VerticalAlignment="Bottom" HorizontalAlignment="Stretch"/>
            <controls:ResizeThumb Width="7" Height="7" Cursor="SizeNWSE" Margin="-6 -6 0 0"
                     VerticalAlignment="Top" HorizontalAlignment="Left"/>
            <controls:ResizeThumb Width="7" Height="7" Cursor="SizeNESW" Margin="0 -6 -6 0"
                     VerticalAlignment="Top" HorizontalAlignment="Right"/>
            <controls:ResizeThumb Width="7" Height="7" Cursor="SizeNESW" Margin="-6 0 0 -6"
                     VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
            <controls:ResizeThumb Width="7" Height="7" Cursor="SizeNWSE" Margin="0 0 -6 -6"
                     VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
        </Grid>
    </ControlTemplate>

    <!-- DragThumb Default Template -->
    <Style TargetType="{x:Type controls:DragThumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:DragThumb}">
                    <Rectangle Fill="Transparent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DesignerItem Style -->
    <Style TargetType="{x:Type diagram:DesignerItem}">
        <Setter Property="MinWidth" Value="25"/>
        <Setter Property="MinHeight" Value="25"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type diagram:DesignerItem}">
                    <Grid DataContext="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}}">
                        <!-- PART_DragThumb -->
                        <controls:DragThumb x:Name="PART_DragThumb" Cursor="SizeAll" />
                        
                        <!-- PART_ResizeDecorator -->
                        <Control x:Name="PART_ResizeDecorator" Visibility="Collapsed" Template="{StaticResource ResizeDecoratorTemplate}" />

                        <!-- PART_ContentPresenter -->
                        <ContentPresenter x:Name="PART_ContentPresenter"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              Content="{TemplateBinding ContentControl.Content}"
                              Margin="{TemplateBinding ContentControl.Padding}"/>
                        <!-- PART_ConnectorDecorator -->
                        <!--<Control x:Name="PART_ConnectorDecorator"
                     Visibility="Hidden"
                     Template="{StaticResource ConnectorDecoratorTemplate}"/>-->
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Value="True" Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}">
                            <Setter TargetName="PART_ResizeDecorator" Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                        <!--<Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="PART_ConnectorDecorator" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <DataTrigger Value="True" Binding="{Binding RelativeSource={RelativeSource Self},Path=IsDragConnectionOver}">
                            <Setter TargetName="PART_ConnectorDecorator" Property="Visibility" Value="Visible"/>
                        </DataTrigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type diagram:Connection}">
        <Style.Resources>
            <!-- Style for the ConnectorAdorner thumbs -->
            <Style x:Key="ConnectionAdornerThumbStyle" TargetType="{x:Type Thumb}">
                <Setter Property="Width" Value="12"/>
                <Setter Property="Height" Value="12"/>
                <Setter Property="SnapsToDevicePixels" Value="true"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TranslateTransform X="-6" Y="-6"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Thumb}">
                            <Rectangle Fill="#AADCDCDC" Stroke="DodgerBlue" StrokeThickness="1" RadiusX="0" RadiusY="0"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <!-- Arrow Grid Style -->
            <Style x:Key="ArrowGridStyle" TargetType="Grid">
                <Setter Property="Width" Value="10"/>
                <Setter Property="Height" Value="10"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TranslateTransform X="-5" Y="-5"/>
                    </Setter.Value>
                </Setter>
            </Style>
            <!-- base style for all arrow shapes -->
            <Style x:Key="ArrowSymbolBaseStyle" TargetType="Path">
                <Setter Property="Fill" Value="{StaticResource SolidBorderBrush}"/>
                <Setter Property="Stretch" Value="Fill"/>
            </Style>
            <!-- Arrow -->
            <Style x:Key="Arrow" TargetType="Path" BasedOn="{StaticResource ArrowSymbolBaseStyle}">
                <Setter Property="Data" Value="M0,0 8,4 0,8 Z"/>
            </Style>
            <!-- Diamond  -->
            <Style x:Key="Diamond" TargetType="Path" BasedOn="{StaticResource ArrowSymbolBaseStyle}">
                <Setter Property="Data" Value="M-5,0 0,-5 5,0 0,5 Z"/>
            </Style>
        </Style.Resources>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type diagram:Connection}">
                    <Grid DataContext="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}}" >
                        <Grid.Resources>
                            <controls:RectConverter x:Key="RectConverter" />
                        </Grid.Resources>

                        <controls:ConnectionPathHelper x:Name="ConnectionPathHelper">
                            <controls:ConnectionPathHelper.SourceRect>
                                <MultiBinding Converter="{StaticResource RectConverter}">
                                    <Binding Path="Source.Left" />
                                    <Binding Path="Source.Top" />
                                    <Binding Path="Source.ActualWidth" />
                                    <Binding Path="Source.ActualHeight" />
                                </MultiBinding>
                            </controls:ConnectionPathHelper.SourceRect>
                            <controls:ConnectionPathHelper.TargetRect>
                                <MultiBinding Converter="{StaticResource RectConverter}">
                                    <Binding Path="Target.Left" />
                                    <Binding Path="Target.Top" />
                                    <Binding Path="Target.ActualWidth" />
                                    <Binding Path="Target.ActualHeight" />
                                </MultiBinding>
                            </controls:ConnectionPathHelper.TargetRect>
                        </controls:ConnectionPathHelper>

                        <controls:ArrowLine
                              x:Name="PART_ConnectionPath" StrokeThickness="2" Stroke="{StaticResource SolidBorderBrush}" StrokeStartLineCap="Round"
                              StrokeEndLineCap="Round" StrokeLineJoin="Round" SnapsToDevicePixels="True"
                              X1="{Binding ArrowStart.X, ElementName=ConnectionPathHelper}"
                              Y1="{Binding ArrowStart.Y, ElementName=ConnectionPathHelper}"
                              X2="{Binding ArrowEnd.X, ElementName=ConnectionPathHelper}"
                              Y2="{Binding ArrowEnd.Y, ElementName=ConnectionPathHelper}" />

                        <!--Uncomment this to show default label text-->
                        <!--<TextBlock Width="100" Height="35" Text="Label"                       
                       Canvas.Left="{Binding LabelPosition.X}"
                       Canvas.Top="{Binding LabelPosition.Y}">
              <TextBlock.RenderTransform>
                <TranslateTransform X="5" Y="5"/>
              </TextBlock.RenderTransform>
            </TextBlock>-->

                        <Grid.BitmapEffect>
                            <DropShadowBitmapEffect Color="Gray" Direction="315" ShadowDepth="10" Softness="0" Opacity="0.1"/>
                        </Grid.BitmapEffect>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!--<Trigger Property="SourceArrow" Value="Arrow">
                            <Setter TargetName="PART_SourceAnchorPath" Property="Style" Value="{StaticResource Arrow}"/>
                        </Trigger>
                        <Trigger Property="SourceArrow" Value="Diamond">
                            <Setter TargetName="PART_SourceAnchorPath" Property="Style" Value="{StaticResource Diamond}"/>
                        </Trigger>
                        <DataTrigger Value="Arrow" Binding="{Binding RelativeSource={RelativeSource Self},Path=SinkArrowSymbol}">
                            <Setter TargetName="PART_SinkAnchorPath" Property="Style" Value="{StaticResource Arrow}"/>
                        </DataTrigger>
                        <DataTrigger Value="Diamond" Binding="{Binding RelativeSource={RelativeSource Self},Path=SinkArrowSymbol}">
                            <Setter TargetName="PART_SinkAnchorPath" Property="Style" Value="{StaticResource Diamond}"/>
                        </DataTrigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>